/**
 * Created by neo on 2016/6/21.\
 * 模态窗口
 */
;(function ($, d) {

    // 详细参数参见  http://aui.github.io/artDialog/doc/index.html#option
    function Modal(option) {
        var that = this;
        that.defaultOption = {
            width:400,
            height:70,
            okValue: "确定",
            cancelValue: "取消",
            cancelDisplay: true
        }
    }

    Modal.prototype = {
        _create: function (option) {
            var that = this;
            that.option = $.extend({}, that.defaultOption, option);
        }
        ,
        show: function (option) {
            var that = this;
            that._create(option)
           return d(that.option).show();
        }
        ,
        showModal: function (option) {
            var that = this;
            that._create(option)
            return d(that.option).showModal();
        }
    }

    $.fn["modal"] = new Modal();
    
})(jQuery, dialog);




/**
 * Created by neo on 2016/6/21.\
 * 消息提示信息
 */
;(function ($, d) {
    function MsgInfo() {
        var that = this;
        return {
            alert: that._alert,
            log: that._log,
            tip: that._tip,
            confirm: that._confirm
        }
    }

    MsgInfo.prototype = {
        _alert: function (msginfo, okcall) {
            return d({
                title: '提示消息',
                fixed: true,
                width: 400,
                content: msginfo,
                okValue: "确定",
                ok: function () {
                    this.close().remove();
                    _.isFunction(okcall) && okcall();
                }
            }).showModal();
        },
        _confirm: function (msg, ok, cancel) {
            return d({
                title: '警告！',
                fixed: true,
                width: 400,
                content: msg || "你确定执行该操作吗?",
                okValue: "确定",
                ok: function () {
                    this.close().remove();
                    _.isFunction(ok) && ok();
                },
                cancelValue: "取消",
                cancel: function () {
                    this.close().remove();
                    _.isFunction(cancel) && cancel();
                }
            }).show();
        },
        _log: function (msginfo) {
            var msgLog = d({
                content: "<span style='color:red;'>" + msginfo + "</span>",
                fixed: true,
                quickClose: true,
                autofocus: false
            }).show();
            setTimeout(function () {
                msgLog.close().remove();
            }, 5000)
        },
        _tip: function (target, msg) {
            return d({
                content: msg,
                quickClose: true,
                autofocus: false
            }).show(target);
        }
    }

    $.fn["msg"] = new MsgInfo();

})(jQuery, dialog);

window.alert2 = $.fn.msg.alert;
window.confirm2 = $.fn.msg.confirm;
/**
 * Created by neo on 2016/10/19.
 */
;(function ($) {
    function _tab(element) {
        var tabBox = element;
        var tabNav = tabBox.find('.nav-tabs');
        var tabContent = tabBox.find('.tab-content');
        var bindEvnet = function () {
            tabNav.find('li').on('click',function () {
                tabNav.find('li.active').removeClass('active');
                $(this).addClass('active');
                var target = $(this).find('a').data("target");
                tabContent.find('.tab-pane.active').removeClass('active');
                tabContent.find('.tab-pane'+target).addClass('active');
            })
            tabNav.find('li').eq(0).trigger('click');
        }
        bindEvnet();
    }
    function tab() {
        this.each(function () {
            var $this = $(this);
            _tab($this);
        })
    }        
    $.fn["tab"] = tab;
})(jQuery)